package com.szy.redstonemcu;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;

public class CallbackButton extends GuiButton {
    private ButtonClickListener listener=new ButtonClickListener() {
        @Override
        public void onClick(int buttonID) {

        }
    };


    public CallbackButton(int buttonId, int x, int y, String buttonText) {
        super(buttonId, x, y, buttonText);
    }

    public CallbackButton(int buttonId, int x, int y, int widthIn, int heightIn, String buttonText) {
        super(buttonId, x, y, widthIn, heightIn, buttonText);
    }

    public CallbackButton setListener(ButtonClickListener listener){
        this.listener=listener;
        return this;
    }
    @Override
    public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
        if(mouseX >= this.x && mouseX < this.x + this.width && mouseY >= this.y && mouseY < this.y + this.height){
            listener.onClick(id);
        }
        return super.mousePressed(mc, mouseX, mouseY);
    }
}
